<?php
/**
 * This file is part of the Agora distribution. 
 * Detailed copyright and licensing information can be found
 * in the gpl-3.0.txt file which should be included in the distribution.
 * 
 * @version		$Id: 3.0.14 Olympus 2010-09-28 rammstein4o $
 * @copyright  2007 - 2010 jVitals
 * @license   GPLv3 Open Source
 * @link       http://jvitals.com
 * @since      File available since initial release
 */
	defined ('IN_AGORA') or die;

	class TaskController extends AgoraPostController
	{
		function _default()
		{
			$this->authenticateTopic($this->id,'delete_topics');

			$topic_model = & Model::getInstance('TopicModel');
			$forum_id = $topic_model->getForumId($this->id);

			$catnav_helper = & $this->helper('catnav');
			$catnav_helper->fromForum($forum_id);
			
			$parser = & $this->helper('parser');
			$post_helper = & $this->helper('post');
			$topics = $topic_model->loadPosts($this->id, 1, 1, false, 1);
			$topics = $post_helper->processPosts($topics, $parser);
			
			$this->view->assignRef('topic',$topics);
		
			$this->view->template = 'post/delete_topic';
		}

		function _save()
		{
			$this->authenticateTopic($this->id,'delete_topics');
			
			$topic_model = & Model::getInstance('TopicModel');
			$forum_id = $topic_model->getForumId($this->id);
			$topic = $topic_model->load($this->id);
			if ($topic['question'])
			{
			    $poll_model = & Model::getInstance('PollModel');
			    $poll_model->delete($this->id);
			}
			$topic_model->delete($this->id);
			$this->redirect('task=forum','id='.$forum_id,'!page','!action');
		}
	}

